home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
__MANDEL
/
MANDELBR
/
CMANDELP.C1
< prev
next >
Wrap
Text File
|
1992-03-25
|
1KB
|
66 lines
// CMandelPictFile.c
#include "CMandelDoc.h"
#include "CMandelMap.h"
#include "CMandelPictFile.h"
#define PICT_HEADER_SIZE 512
static OSErr sPutError;
static long sPutCount;
static CMandelPictFile * sFile;
extern PicHandle gPixPictH;
extern OSErr gLastError;
void CMandelPictFile::IMandelPictFile(CMandelDoc *theMandelDoc)
{
CDataFile::IDataFile();
itsMandelDoc = theMandelDoc;
}
static pascal void MyPutPicProc(Ptr theDataP, unsigned theCount);
static pascal void MyPutPicProc(Ptr theDataP, unsigned theCount)
{
sPutCount += theCount;
if (gPixPictH)
(**gPixPictH).picSize = sPutCount;
if (sPutError) return;
TRY {
sFile->WriteSome(theDataP, theCount);
}
CATCH {
sPutError = gLastError;
NO_PROPAGATE;
}
ENDTRY;
}
void CMandelPictFile::WriteAll(Handle theDataH)
{
CMandelMap *aMandelMap = itsMandelDoc->GetMandelMap();
Handle aH;
PicHandle aPictH;
aH = NewHandleClear(PICT_HEADER_SIZE + sizeof(Picture));
FailNIL(aH);
WriteSome(*aH, PICT_HEADER_SIZE + sizeof(Picture));
DisposHandle(aH);
sPutError = noErr;
sPutCount = sizeof(Picture);
sFile = this;
aMandelMap->SetPutPicProc((ProcPtr)MyPutPicProc);
aPictH = aMandelMap->GetPicHandle();
aMandelMap->ResetStdProcs();
SetMark((long)PICT_HEADER_SIZE, fsFromStart);
WriteSome((Ptr)*aPictH, sizeof(Picture));
KillPicture(aPictH);
}